# Contributor: Ivan Tham <pickfire@riseup.net>
# Maintainer:
pkgname=opencc
_pkgname=OpenCC
pkgver=1.1.3
pkgrel=0
pkgdesc="Open Chinese Convert"
url="https://opencc.byvoid.com/"
arch="all"
license="Apache-2.0"
makedepends="
	cmake
	doxygen
	libmarisa-dev
	python3
	rapidjson-dev
	tclap-dev
	samurai
	"
subpackages="$pkgname-dev $pkgname-doc"
source="https://github.com/BYVoid/opencc/archive/refs/tags/ver.$pkgver/OpenCC-ver.$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-ver.$pkgver"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_DOCUMENTATION=ON \
		-DBUILD_TESTING=OFF \
		-DUSE_SYSTEM_MARISA=ON \
		-DUSE_SYSTEM_RAPIDJSON=ON \
		-DUSE_SYSTEM_TCLAP=ON \
		$CMAKE_CROSSOPTS
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	mkdir -p "$pkgdir"/usr/share/doc
	mv "$pkgdir"/usr/share/opencc/doc "$pkgdir"/usr/share/doc/opencc
}

sha512sums="
90da656fa4790c58932ad2240a076cc4a9e8cf70ac73d83e0d299e84472deb6491a823966a7686ed1487ef8405909981b9a12b661d8de7f086bd4b498594abac  OpenCC-ver.1.1.3.tar.gz
"
